<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios 调用方法发送请求</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>

</head>
<body>
    <button>get</button>
    <button>post</button>

    <script>
        //发送请求  axios()
        let btns = document.querySelectorAll('button');

        btns[0].onclick = async function(){
            //发送请求 post  put  delete  patch
            let result = await axios.get('http://127.0.0.1:3000/movie');
            console.log(result);
        }

        btns[1].onclick = async function(){
            //发送请求                        URL                        请求体
            let result = await axios.post('http://127.0.0.1:3000/movie', {name: '楚门的世界', director: '忘了'});
            
            console.log(result);
        }
    </script>
</body>
</html>